package com.wrial.kind.linkedList;
/*
 * @Author  Wrial
 * @Date Created in 18:37 2020/8/7
 * @Description
 *
 * 有序的链表，删除重复元素
 */

public class DeleteDuplicates {


    public ListNode deleteDuplicates(ListNode head) {
        ListNode ans = head;
        while (head != null && head.next != null) {
            if (head.val==head.next.val){
                head.next = head.next.next;
            }else {
                head = head.next;
            }
        }
        return ans;
    }

    public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}
